package com.ybf.api.service.impl;

import cn.dev33.satoken.stp.StpUtil;
import com.github.pagehelper.PageHelper;
import com.ybf.api.entity.PageRequest;
import com.ybf.api.entity.PageResult;
import com.ybf.api.entity.RolePermissions;
import com.ybf.api.mapper.RolePermissionsMapper;
import com.ybf.api.service.RolePermissionsService;
import com.ybf.api.utils.EncryptUtils;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author ybf
 * @since 2024-09-26
 */
@Service("RolePermissionsService")
public class RolePermissionsImpl implements RolePermissionsService {

    @Resource
    private RolePermissionsMapper rolepermissionsMapper;

    @Override
    public PageResult<RolePermissions> list(RolePermissions rolepermissions, PageRequest pageRequest) {
        PageHelper.startPage(pageRequest);
        List<RolePermissions> list = rolepermissionsMapper.list(rolepermissions);
        PageResult<RolePermissions> pageResult = new PageResult<RolePermissions>(list);
        return pageResult;
    }

    @Override
    public RolePermissions info(Integer id) {
        return rolepermissionsMapper.info(id);
    }

    @Override
    public Boolean delete(Integer id) {
        return rolepermissionsMapper.delete(id) > 0;
    }

    @Override
    public Integer edit(RolePermissions rolepermissions) {
        if (rolepermissions.getId() != null) {
            return rolepermissionsMapper.edit(rolepermissions);
        }
        return rolepermissionsMapper.add(rolepermissions);
    }
}
